<template>
	<view>
		<home :cur="PageCur" v-if="PageCur=='home'" :key="commponent1Key"></home>
		<people v-if="PageCur=='people'" :key="commponent2Key"></people>
		<jobTicketIssuance v-if="PageCur=='jobTicketIssuance'" :key="commponent3Key"></jobTicketIssuance>
		
		<view class="cu-bar tabbar bg-white shadow foot">	
			<view :class="PageCur=='home'?'action text-green':'action text-gray'" @click="NavChange" data-cur="home">
				<view class="cuIcon-homefill"></view> 首页
			</view>
			<view :class="PageCur=='jobTicketIssuance'?'action text-green':'action text-gray'" @click="NavChange" data-cur="jobTicketIssuance">
				<view class="cuIcon-similar"></view> 作业签发
			</view>
			<view class="action text-gray add-action">
				<button class="cu-btn cuIcon-add bg-green shadow" @click="shareToggle"></button>
				随手拍
			</view>
			<view :class="PageCur=='profile'?'action text-green':'action text-gray'" @click="NavChange" data-cur="profile">
				<view class="cuIcon-cart">
					<view class="cu-tag badge">99</view>
				</view>
				购物车
			</view>
			<view :class="PageCur=='people'?'action text-green':'action text-gray'" @click="NavChange" data-cur="people">
				<view class="cuIcon-my">
					<view class="cu-tag badge"></view>
				</view>
				我的
			</view>
		</view>
		
		<view class="bounced">
			<uni-popup ref="share" type="share" safeArea backgroundColor="#fff">
				<uni-popup-risk :title="titleText" :localData="bottomData" @select="shareToggleSelect" @close="shareToggleClose"></uni-popup-risk>
			</uni-popup>
		</view>
		
	</view>
</template>

<script>
	export default {
		data() {
		return {
				PageCur: 'home',
				commponent1Key: 0,
				commponent2Key: 0,
				commponent3Key: 0,
				titleText: "快捷任务",
				bottomData: [{
					text: '新增隐患',
					icon: '/static/icon/dengjisvg.png',
					name: 'hidden',
					url: '../doubleControl/dangerInvestigationReocrd/dangerInvestigationReocrdSignIn'
				},
				{
					text: '扫码排查',
					icon: '/static/icon/saoma.png',
					name: 'scan',
					url: ''
				},
				{
					text: '直接开票',
					icon: '/static/icon/liucheng.png',
					name: 'scan',
					url: ''
				},
				{
					text: '人脸识别',
					icon: '/static/icon/saoma.png',
					name: 'scan',
					url: ''
				},
				]
			}
		},
		onLoad:function(){
			this.PageCur='home'
			++this.commponent1Key
			++this.commponent2Key
			++this.commponent3Key
		},
		methods: {
			NavChange: function(e) {
				this.PageCur = e.currentTarget.dataset.cur
			},
			shareToggle() {
				this.$refs.share.open("bottom")
			},
			shareToggleSelect(selectRow) {
				console.log("----selectRow----------"+JSON.stringify(selectRow))
				if(selectRow.item.name == "hidden"){
					uni.navigateTo({
					 	url: selectRow.item.url
					})
				}else if(selectRow.item.name == "scan"){
					this.scanCode();
				}
			},
			shareToggleClose(){
				this.$refs.share.close()
			},
			scanCode() {
				// 允许从相机和相册扫码
				uni.scanCode({
					success: function(res) {
						if(res.result){//如果扫码内容不为空就路由去岗位排查界面
							console.log('条码类型：' + res.scanType);
							console.log('条码内容-----------：' + res.result);
							uni.navigateTo({
								url: "/pages/doubleControl/riskTask/riskTaskList?riskUnitId="+res.result+"&type="+res.scanType
							})
						}
					}
				});
			},
		}
	}
</script>

<style>
.popup-content {
	height: 200px;
	border-radius: 8%;
}
.contentflex{
	width: 100%;
	height: 100%;
	display: flex;
	flex-direction: row;
}
.rowflex{
	flex: 1.6;
	margin-top: 25px;
	text-align: center;
	font-size: 16px;
}
.rowflex1{
	flex: .3;
}
.couleflex{
	flex: 1.6;
	margin-top: 25px;
	text-align: center;
	font-size: 16px;
}
.couleflex1{
	flex: .3;
}
</style>
